#include <iostream>
#include <string>

#define PI 3.141

using namespace std;

// Abstract factory implmentation, with a seperate factory class
// The big difference with the static implementation is that here we
// use a dedicated factory class to create the objects on run-time
// The static implmentation uses the super class to have a function to create
// objects. It uses the friend keyword to give the create function access to the 
// sub classes so that the member function of the classes can be accessed (they will overwrite)
// the virtual functions.

// Abstract class
class Car{

public:
	// Pure virtual function thats will get overridden
	virtual void GetType() = 0;

	void GetEngine(){
		cout << Engine << endl;
	}

private:
	string Engine;
};


// Concrete sub-class
class Toyota : public Car{

public:
	void GetType(){
		cout << "Toyota" << endl;
	}

private:

};

// Concrete sub-class
class Doge : public Car{

public:
	void GetType(){
		cout << "Doge" << endl;
	}

private:

};

// Abstract Factory returning a car
class CarFactory {
public:
	// Create a car type
	Car* CreateCar(string type);
};

// Function to create a car
Car* CarFactory::CreateCar(string type) {
	if (type == "Toyota"){
		return new Toyota();
	}

	if (type == "Doge"){
		return new Doge();
	}

	return NULL;
}